package com.agiantii.ablog.handler.article.chain.impl;

import com.agiantii.ablog.handler.article.chain.BaseContentHandler;
import com.agiantii.ablog.pojo.dto.PostDTO;
import org.springframework.stereotype.Component;

@Component
public class WordCountHandler extends BaseContentHandler {
    private static final int MIN_WORDS = 2;
    private static final int MAX_WORDS = 10000;
    
    @Override
    public boolean handle(PostDTO content) {
        int wordCount = content.getContent().length();
        if (wordCount < MIN_WORDS) {
            throw new IllegalArgumentException("文章内容太短，至少需要" + MIN_WORDS + "个字");
        }
        if (wordCount > MAX_WORDS) {
            throw new IllegalArgumentException("文章内容太长，最多允许" + MAX_WORDS + "个字");
        }
        return handleNext(content);
    }
} 